home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / sound / sample20.zip / SAMPLER.DOC < prev    next >
Text File  |  1989-05-04  |  32KB  |  674 lines

  1.  
  2.  
  3.  
  4.      Digital Sound Sample Playback and Manipulation System     
  5.      -----------------------------------------------------
  6.  
  7.  
  8.           Version 2.0        Rowan McKenzie  28/3/89
  9.  
  10.  
  11.                    (C) Copyright 1989 by Rowan McKenzie
  12.  
  13.                   You may copy these files  or use the source  code  only 
  14.         for non-profit purposes. Please contact me if you wish to use any 
  15.         part of the package for commercial purposes. 
  16.                   I accept  no responsibility for any  injury  or  damage 
  17.         caused by the use of any of these files.
  18.  
  19.  
  20.  
  21.  
  22.      SAMPLER/PWMSAMPL  is true public domain. In other words, I ask for  no 
  23. payment, registration fee, donations.... But please distribute these  files 
  24. in  the form you found them. Also I would appreciate acknowledgment in  any 
  25. programs which use sections of my source code.
  26.  
  27.  
  28.  
  29.  
  30.      Introduction
  31.      ------------
  32.  
  33.  
  34.      SAMPLER    and    PWMSAMPL    are    packages    for    playing    and           
  35. manipulating  digitised  sound  samples.  SAMPLER  expects  an  8  bit  D/A 
  36. converter  to be available on a parallel printer port, while PWMSAMPL  will 
  37. play  sounds on the PC speaker using pulse width modulation. Of course  the 
  38. quality  of sound will be much better for the D/A version, however the  PWM 
  39. version requires no additional hardware.
  40.  
  41.      Support is provided for playing Pianoman .MUS files as songs using the 
  42. current sampled sound.
  43.  
  44.  
  45.  
  46.      Hardware Requirements
  47.      ---------------------
  48.  
  49.      PWMSAMPL requires:
  50.  
  51.           IBM XT/AT or close compatible
  52.  
  53.           Hercules, CGA or EGA graphics card
  54.  
  55.  
  56.      SAMPLER requires in addition to the above:
  57.  
  58.           An  8  bit D/A converter connected to  a  parallel 
  59.           printer port
  60.  
  61.           If  the sampling feature is to be used, a  fast  8 
  62.           bit a/d converter is required (although the source 
  63.           code  will  probably  need to  modified  for  your 
  64.           setup).
  65.  
  66.  
  67.      Software Requirements
  68.      ---------------------
  69.  
  70.           MSDOS Ver 2.00 or later
  71.  
  72.           Pianoman  program  and support files  (PCblue  Vol 
  73.           216, PCsig Vol 279) if the song mode is to used
  74.  
  75.  
  76.  
  77.  
  78.      Background
  79.      ----------
  80.  
  81.      SAMPLER  and  PWMSAMPL were derived from an A/D,  D/A  sound  sampling 
  82. system I wrote for an old CPM computer system. 
  83.  
  84.      The  pulse width modulation code uses the 8253 timer chip in one  shot 
  85. mode  to  drive  the PC speaker with variable length pulses at  a  rate  of 
  86. about 20kHz. Varying the pulse length produces the same result  as  varying 
  87. the  voltage on a linearly controlled speaker. Unfortunately, the  software 
  88. overhead for this could mean that slow XT systems may not be fast enough to 
  89. run  PWMSAMPL.  Also  the sound volume is quite low (it's  limited  by  the 
  90. difference  between the shortest and longest pulses used, which is  limited 
  91. by  the  sample rate, which is 20kHz for reasonable quality), so  you  will 
  92. need to listen in a quiet room, or else build a D/A converter for SAMPLER !
  93.  
  94.      If  you  are interested in building a D/A converter to hear  the  much 
  95. better sound quality of SAMPLER, a standard R-2R resistor ladder (R ~  10k) 
  96. into an amplifier of reasonably high input impedance (or low impedance  via 
  97. a  100k resistor) will be quite adequate. Alternatively, an active  circuit 
  98. using a chip such as the DAC0800 with its own power supply could be  built. 
  99. The circuit shown below worked adequately for me.
  100.  
  101.  
  102. D7 --- 20k ---+--- 200k ----->  to amplifier
  103.               |
  104.              10k
  105.               |
  106. D6 --- 20k ---+
  107.               |
  108.              10k
  109.               |
  110. D5 --- 20k ---+
  111. p             |
  112. r
  113. i           etc ...
  114. n
  115. t             |
  116. e            10k
  117. r             |
  118. D0 --- 20k ---+
  119.               |
  120.              20k
  121.               |
  122.    =============== gnd
  123.  
  124.  
  125.  
  126.      To  utilise  the sampling feature, a fast (at least  20kHz  conversion 
  127. rate) A/D converter must be available. My converter was designed to begin a 
  128. conversion following a CPU access. As long as samples are taken at  regular 
  129. intervals,  this  technique  minimises  I/O  overheads.  The  converter  is 
  130. addressed  at the same location as the D/A converter to simplify the  code. 
  131. If your converter doesn't meet these specifications (probably won't),  then 
  132. the  assembler code will require modification. SAMPLER is written in  Turbo 
  133. Pascal Version 5, and the font and driver units can only be used with  that 
  134. compiler.
  135.  
  136.  
  137.  
  138.  
  139.      Using SAMPLER / PWMSAMPL
  140.      ------------------------
  141.  
  142.      Version  2.0 of SAMPLER now uses mouse control rather than  cumbersome 
  143. keyboard commands. It is therefore necessary to have an MSMOUSE (R)  driver 
  144. installed  before  starting the program. Most mouse packages come  with  an 
  145. MSMOUSE  compatible driver and either two or three button mouses will  work 
  146. fine.  If a mouse is unavailable, the cursor keys provide mouse  emulation, 
  147. although this makes controlling SAMPLER more difficult. 
  148.  
  149.      If  you  are using a mouse, generally the left  mouse  button  selects 
  150. objects  while the right button cancels. The exception to this is for  wave 
  151. drawing where the right button enables drawing. Dialog boxes which  contain 
  152. a  Continue prompt expect you to click on the box containing  the  Continue 
  153. prompt,  although  the  right mouse button will have  the  same  effect  by 
  154. canceling the prompt. Also, pressing Enter in this situation will cause the 
  155. program  to continue. You will notice that while a sound is being  replayed 
  156. no mouse activity is possible. It was necessary to disable mouse interrupts 
  157. while producing sounds to avoid overloading the CPU. However, mouse control 
  158. can  be temporarily restored during sounds by holding down the right  shift 
  159. key.
  160.  
  161.      If no mouse is available, the arrow keys provide coarse mouse control, 
  162. and the left shift key together with the arrow keys provides fine  control. 
  163. The  left  button  is emulated with the Alt key, and the  right  button  is 
  164. replaced by the Ctrl key. For compatibility with my other mouse  controlled 
  165. programs,  the  Caps lock key performs the same function as  Ctrl,  however 
  166. because a custom keyboard handler intercepts keyboard information, the caps 
  167. lock key can become confused. If the Caps Lock LED ever comes on, it may be 
  168. necessary to press Caps lock again before the program will continue.
  169.  
  170.      When  SAMPLER  is  first  started  by  typing  SAMPLER  or   PWMSAMPL, 
  171. information   will  be  displayed  about  the  default  settings   of   the 
  172. configuration  file. When the default sound file has loaded, a  dialog  box 
  173. containing  all current settings will appear. Normally this is  ignored  by 
  174. clicking on the continue box (or canceling with the right button or Enter), 
  175. however, you may wish to alter an option before starting. 
  176.  
  177.      Once  you  are  past the initial dialog box, a  plot  of  the  current 
  178. waveform  will appear, together with several other objects. At the  top  of 
  179. the  screen  appears a group of menu headings. Clicking on a  heading  will 
  180. bring  a  sub-menu  down.  All SAMPLER functions now  appear  in  the  menu 
  181. structure,  and no keyboard commands exist. The state of the more  relevant 
  182. toggle-able functions and variables is given in a panel near the top of the 
  183. screen,  all  of  which may be changed from the Settings box  in  the  menu 
  184. (under  Options). The current waveform appears in the center of the  screen 
  185. with  the current start, end and loop arrows above and below. At the  lower 
  186. right  is a collection of click-boxes which control the pitch of the  sound 
  187. when  replayed. The vertical arrows control the octave of the sound,  while 
  188. the large and small left/right arrows alter the pitch within an octave. The 
  189. larger  arrows  provide  coarse control. The Reset  box  will  restore  the 
  190. original default replay pitch, canceling the effect of other boxes. At  the 
  191. lower  right  of the screen are a similar set of boxes  which  control  the 
  192. period of the auto-timer. The auto-timer determines the rate of "auto sound 
  193. repea